package com.chj.design.sk;

public class Code13_Proxy {
	public interface ICoder {

		public void implDemands(String demandName);

	}

	public static class JavaCoder implements ICoder {

		private String name;

		public JavaCoder(String name) {
			this.name = name;
		}

		@Override
		public void implDemands(String demandName) {
			System.out.println(name + " implemented demand:" + demandName + " in JAVA!");
		}
	}

	public static class CoderProxy implements ICoder {

		private ICoder coder;

		public CoderProxy(ICoder coder) {
			this.coder = coder;
		}

		@Override
		public void implDemands(String demandName) {
			if (demandName.startsWith("Add")) {
				System.out.println("No longer receive 'Add' demand");
				return;
			}
			coder.implDemands(demandName);
		}
	}

	public static void main(String[] args) {
		// 定义一个java码农
		ICoder coder = new JavaCoder("Zhang");
		// 定义一个产品经理
		ICoder proxy = new CoderProxy(coder);
		// 让产品经理实现一个需求
		proxy.implDemands("change login process");
		proxy.implDemands("Add login process");
	}
}
